package org.redrider.shop.domain
class WorkOrderSplits {
    Float hours
    String explanation
    Float hourlyRate
    Float rateFudge
    Float cost
    String type

    static transients = ['cost','hourlyRate']
    static belongsTo = [workOrder:WorkOrder]
    static constraints = {
        hours()
        explanation(size:0..10000)
        type(inList:['Labor','Sub-Contractor'])
        hourlyRate()
        rateFudge(blank:true, nullable:true)
        cost()
    }

    Float getHourlyRate(){
            return workOrder.tech.hourlyRate
    }

    Float getCost(){
        return hours * (workOrder.tech.hourlyRate - rateFudge)
    }
}
